// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.Analysis;

public sealed partial class PathHierarchyTokenizer : ITokenizer
{
	[JsonInclude, JsonPropertyName("buffer_size")]
	public int? BufferSize { get; set; }
	[JsonInclude, JsonPropertyName("delimiter")]
	public string? Delimiter { get; set; }
	[JsonInclude, JsonPropertyName("replacement")]
	public string? Replacement { get; set; }
	[JsonInclude, JsonPropertyName("reverse")]
	public bool? Reverse { get; set; }
	[JsonInclude, JsonPropertyName("skip")]
	public int? Skip { get; set; }

	[JsonInclude, JsonPropertyName("type")]
	public string Type => "path_hierarchy";

	[JsonInclude, JsonPropertyName("version")]
	public string? Version { get; set; }
}

public sealed partial class PathHierarchyTokenizerDescriptor : SerializableDescriptor<PathHierarchyTokenizerDescriptor>, IBuildableDescriptor<PathHierarchyTokenizer>
{
	internal PathHierarchyTokenizerDescriptor(Action<PathHierarchyTokenizerDescriptor> configure) => configure.Invoke(this);

	public PathHierarchyTokenizerDescriptor() : base()
	{
	}

	private int? BufferSizeValue { get; set; }
	private string? DelimiterValue { get; set; }
	private string? ReplacementValue { get; set; }
	private bool? ReverseValue { get; set; }
	private int? SkipValue { get; set; }
	private string? VersionValue { get; set; }

	public PathHierarchyTokenizerDescriptor BufferSize(int? bufferSize)
	{
		BufferSizeValue = bufferSize;
		return Self;
	}

	public PathHierarchyTokenizerDescriptor Delimiter(string? delimiter)
	{
		DelimiterValue = delimiter;
		return Self;
	}

	public PathHierarchyTokenizerDescriptor Replacement(string? replacement)
	{
		ReplacementValue = replacement;
		return Self;
	}

	public PathHierarchyTokenizerDescriptor Reverse(bool? reverse = true)
	{
		ReverseValue = reverse;
		return Self;
	}

	public PathHierarchyTokenizerDescriptor Skip(int? skip)
	{
		SkipValue = skip;
		return Self;
	}

	public PathHierarchyTokenizerDescriptor Version(string? version)
	{
		VersionValue = version;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (BufferSizeValue.HasValue)
		{
			writer.WritePropertyName("buffer_size");
			writer.WriteNumberValue(BufferSizeValue.Value);
		}

		if (!string.IsNullOrEmpty(DelimiterValue))
		{
			writer.WritePropertyName("delimiter");
			writer.WriteStringValue(DelimiterValue);
		}

		if (!string.IsNullOrEmpty(ReplacementValue))
		{
			writer.WritePropertyName("replacement");
			writer.WriteStringValue(ReplacementValue);
		}

		if (ReverseValue.HasValue)
		{
			writer.WritePropertyName("reverse");
			writer.WriteBooleanValue(ReverseValue.Value);
		}

		if (SkipValue.HasValue)
		{
			writer.WritePropertyName("skip");
			writer.WriteNumberValue(SkipValue.Value);
		}

		writer.WritePropertyName("type");
		writer.WriteStringValue("path_hierarchy");
		if (!string.IsNullOrEmpty(VersionValue))
		{
			writer.WritePropertyName("version");
			writer.WriteStringValue(VersionValue);
		}

		writer.WriteEndObject();
	}

	PathHierarchyTokenizer IBuildableDescriptor<PathHierarchyTokenizer>.Build() => new()
	{
		BufferSize = BufferSizeValue,
		Delimiter = DelimiterValue,
		Replacement = ReplacementValue,
		Reverse = ReverseValue,
		Skip = SkipValue,
		Version = VersionValue
	};
}